
//? 实现每隔一段时间执行函数 总共执行count次

//? 首先为了次数 肯定得有闭包
function repeat(fn,count,time) {
    return async function (...args) {
        for (let i = 0; i < count; i++) {
            await one(fn,time,...args)
        }
    }
}

function one(fn,time,...args) {
    return new Promise(resolve => {
        setTimeout(() => {
            fn.apply(this,args)
            resolve()
        },time)
    })
}


const repeatLog = repeat(console.log,5,1000)
repeatLog("hello world")
